

function mapChart(showTool) {
    var geoCoordMap = {
        "安徽": ['117.283042', '31.86119'],
        "香港": [114.154334, 22.281931],
        "新疆": [87.617733, 43.792818],
        "西藏": [91.132212, 29.660361],
        "云南": [102.712251, 25.040609],
        "浙江": [120.153576, 30.287459]
    };
    var data = [
        {
            name: "安徽",
            attr: {
                id: "anhui"
            },
            value: 0
        },
        {
            name: "澳门",
            attr: {
                id: "aomen"
            },
            value: 199
        },
        {
            name: "北京",
            attr: {
                id: "beijing"
            },
            value: 123
        },
        {
            name: "重庆",
            attr: {
                id: "chongqing"
            },
            value: 24
        },
        {
            name: "福建",
            attr: {
                id: "fujian"
            },
            value: 116
        },
        {
            name: "甘肃",
            attr: {
                id: "gansu"
            },
            value: 137
        },
        {
            name: "广东",
            attr: {
                id: "guangdong"
            },
            value: 91
        },
        {
            name: "广西",
            attr: {
                id: "guangxi"
            },
            value: 59
        },
        {
            name: "贵州",
            attr: {
                id: "guizhou"
            },
            value: 59
        },
        {
            name: "海南",
            attr: {
                id: "hainan"
            },
            value: 59
        },
        {
            name: "河北",
            attr: {
                id: "hebei"
            },
            value: 59
        },
        {
            name: "黑龙江",
            attr: {
                id: "heilongjiang"
            },
            value: 59
        },
        {
            name: "河南",
            attr: {
                id: "henan"
            },
            value: 59
        },
        {
            name: "湖北",
            attr: {
                id: "hubei"
            },
            value: 59
        },
        {
            name: "湖南",
            attr: {
                id: "hunan"
            },
            value: 59
        },
        {
            name: "江苏",
            attr: {
                id: "jiangsu"
            },
            value: 59
        },
        {
            name: "江西",
            attr: {
                id: "jiangxi"
            },
            value: 59
        },
        {
            name: "吉林",
            attr: {
                id: "jilin"
            },
            value: 59
        },
        {
            name: "辽宁",
            attr: {
                id: "liaoning"
            },
            value: 59
        },
        {
            name: "内蒙古",
            attr: {
                id: "neimenggu"
            },
            value: 14
        },
        {
            name: "宁夏",
            attr: {
                id: "ningxia"
            },
            value: 14
        },
        {
            name: "青海",
            attr: {
                id: "qinghai"
            },
            value: 14
        },
        {
            name: "山东",
            attr: {
                id: "shandong"
            },
            value: 14
        },
        {
            name: "上海",
            attr: {
                id: "shanghai"
            },
            value: 14
        },
        {
            name: "山西",
            attr: {
                id: "shanxi"
            },
            value: 14
        },
        {
            name: "陕西",
            attr: {
                id: "shanxi1"
            },
            value: 14
        },
        {
            name: "四川",
            attr: {
                id: "sichuan"
            },
            value: 14
        },
        {
            name: "台湾",
            attr: {
                id: "taiwan"
            },
            value: 14
        },
        {
            name: "天津",
            attr: {
                id: "tianjin"
            },
            value: 14
        },
        {
            name: "香港",
            attr: {
                id: "xianggang"
            },
            value: 14
        },
        {
            name: "新疆",
            attr: {
                id: "xinjiang"
            },
            value: 14
        },
        {
            name: "西藏",
            attr: {
                id: "xizang"
            },
            value: 14
        },
        {
            name: "云南",
            attr: {
                id: "yunnan"
            },
            value: 14
        }
        ,
        {
            name: "浙江",
            attr: {
                id: "zhejiang"
            },
            value: 0
        }
    ];
    debugger
    var convertData = function (data) {
        var res = [];
        for (var i = 0; i < data.length; i++) {
            var geoCoord = geoCoordMap[data[i].name];
            console.log(geoCoord)
            if (geoCoord) {
                res.push({
                    name: data[i].name,
                    value: geoCoord.concat(data[i].value)
                });
            }
        }
        return res;
    };
    return option3 = {
        grid: {
            left: '0%',
            top: '0%',
            bottom: '15%',
            right: '0%'
        },
        tooltip: {
            trigger: 'item',
            // triggerOn:'click',
            formatter: function (params) {
                var str = '';
                if (params.value && typeof params.value == 'object') {
                    str += '<div class="mapMsg"><span class="cname">' + params.name + '</span><span class="count">项目数：<i>' + params.value[2] + '</i></span></div>'
                    return str
                } else if (params.value) {
                    str += '<div class="mapMsg"><span class="cname">' + params.name + '</span><span class="count">项目数：<i>' + params.value + '</i></span></div>'
                    return str
                }
            }
        },
        legend: {
            orient: 'vertical',
            y: 'bottom',
            x: 'right',
            data: ['pm2.5'],
            textStyle: {
                color: '#fff'
            }
        },
        toolbox: {
            right: '50',
            top: '5',
        },
        visualMap: {
            show: false,
            min: 0,
            max: 500,
            left: 'left',
            top: 'bottom',
            text: ['高', '低'], // 文本，默认为数值文本
            calculable: true,
            seriesIndex: [1],
            inRange: {

            }
        },
        geo: {
            map: 'china',
            show: true,
            zoom: 1.2,
            scaleLimit: {
                min: 1.2,
                max: 1.2
            },
            label: {
                normal: {
                    show: false
                },
                emphasis: {
                    show: false,
                }
            },
            // 隐掉南海诸岛
            regions: [{
                name: "南海诸岛",
                itemStyle: {
                    // 隐藏地图
                    normal: {
                        opacity: 1, // 为 0 时不绘制该图形
                    }
                },
                label: {
                    show: false // 隐藏文字
                }
            }],
            itemStyle: {
                normal: {
                    areaColor: '#3a7fd5',
                    borderColor: '#fff', //线
                    shadowColor: '#092f8f',//外发光
                    shadowBlur: 20
                },
                emphasis: {
                    areaColor: '#0a2dae', //悬浮区背景
                }
            }
        },
        series: [
            {
                type: 'map',
                map: 'china',
                geoIndex: 0,
                aspectScale: 0.75, //长宽比
                showLegendSymbol: false, // 存在legend时显示
                //label: {
                //    normal: {
                //        show: false
                //    },
                //    emphasis: {
                //        show: false,
                //        textStyle: {
                //            color: '#fff'
                //        }
                //    }
                //},
                roam: true,
                //itemStyle: {
                //    normal: {
                //        areaColor: '#031525',
                //        borderColor: '#FFFFFF',
                //    },
                //    emphasis: {
                //        areaColor: '#2B91B7'
                //    }
                //},
                //animation: false,
                data: data
            },
            {
                //悬浮层汉字样式
                symbolSize: 5,
                label: {
                    show: false,
                    normal: {
                        formatter: '{b}',
                        position: 'right',
                        show: true
                    },
                    emphasis: {
                        show: true
                    }
                },
                itemStyle: {
                    normal: {
                        color: '#fff'
                    }
                },
                name: 'light',
                type: 'scatter',
                coordinateSystem: 'geo',
                data: convertData(data)
                // data: data,
            },
            {
                //数据显示悬浮窗
                name: 'Top 5',
                type: 'scatter',
                coordinateSystem: 'geo',
                symbol: 'circle',
                symbolSize: [10, 10],
                itemStyle: {
                    normal: {
                        color: 'rgb(204,255,102,.8)',
                        borderColor: 'rgba(204,255,102,.5)',
                        borderWidth: 10,
                        shadowBlur: 30,
                        shadowColor: 'rgb(204,255,102)',
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                    }
                },
                data: convertData(data),
                showEffectOn: 'render',
                rippleEffect: {
                    brushType: 'stroke'
                },
                hoverAnimation: true,
                zlevel: 1
            }
        ]
    };
}
 

